package com.dd.edu.flashsale.portal.utils;

import lombok.Data;

@Data
public class Message {
    public final static int CODE_SUCCESS = 200;
    public final static int CODE_FAIL = 201;

    private int code;
    private Object data;
    private String msg;

    public Message(int codeSuccess) {
        this.code = codeSuccess;
    }

    public static Message success(){
        Message message = new Message(Message.CODE_SUCCESS);
        return message;
    }

    public static Message success(Object data){
        Message message = new Message(Message.CODE_SUCCESS);
        message.setData(data);
        return message;
    }

    public static Message fail(String msg){
        Message message = new Message(Message.CODE_FAIL);
        message.setMsg(msg);
        return message;
    }
}
